Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support atomic batch transactions #30271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Feb 12, 2025

Description

Support atomic batch transactions via EIP-5792 and EIP-7702.

Specifically:

  • Upgrade @metamask/transaction-controller to support adding batch transactions.
  • Upgrade @metamask/eth-json-rpc-middleware to validate and process EIP-5792 RPC requests.
  • Patch @etheremjs/tx to fix nonce type in EIP-7702 authorizations.
  • Add EIP-5792 utils to provide hooks for middleware.
  • Add minimal support for TransactionType.batch in confirmations.

Open in GitHub Codespaces

Related issues

Fixes #4209

Manual testing steps

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@matthewwalsh0 matthewwalsh0 added the team-confirmations Push issues to confirmations team label Feb 12, 2025
@matthewwalsh0
Copy link
Member Author

@metamaskbot update-policies

Copy link

socket-security bot commented Feb 13, 2025

Updated and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/[email protected]15.3.0 None 0 196 kB gudahtt
npm/@metamask/[email protected]48.0.0-preview-22387993 None 0 0 B

View full report↗︎

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@matthewwalsh0 matthewwalsh0 changed the title feat: support atomic batch transactions via EIP-5792 feat: support atomic batch transactions Feb 18, 2025
@matthewwalsh0 matthewwalsh0 force-pushed the feat/atomic-batch-transactions branch from f377c94 to 29af3c0 Compare February 18, 2025 23:59
@matthewwalsh0
Copy link
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@matthewwalsh0
Copy link
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [d9364b5]
Page Load Metrics (1708 ± 101 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30119911537418201
domContentLoaded145524751687212102
load146524891708210101
domInteractive15175574723
backgroundConnect95925168
firstReactRender1467342211
getState467272412
initialActions01000
loadScripts10421929126418086
setupStore77216178
uiStartup171929101984256123
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.2 MiB (-19.67%)
  • ui: -40.9 KiB (-0.54%)
  • common: -1.12 MiB (-12.29%)

1 similar comment
@metamaskbot
Copy link
Collaborator

Builds ready [d9364b5]
Page Load Metrics (1708 ± 101 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30119911537418201
domContentLoaded145524751687212102
load146524891708210101
domInteractive15175574723
backgroundConnect95925168
firstReactRender1467342211
getState467272412
initialActions01000
loadScripts10421929126418086
setupStore77216178
uiStartup171929101984256123
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.2 MiB (-19.67%)
  • ui: -40.9 KiB (-0.54%)
  • common: -1.12 MiB (-12.29%)

@metamaskbot
Copy link
Collaborator

Builds ready [11fd386]
Page Load Metrics (1799 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29420761589530254
domContentLoaded15062068177314569
load15102081179914971
domInteractive25207413919
backgroundConnect884292110
firstReactRender1473402512
getState474212411
initialActions01000
loadScripts10471531133913364
setupStore7141021
uiStartup17582372207816881
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.2 MiB (-19.67%)
  • ui: -40.9 KiB (-0.54%)
  • common: -1.12 MiB (-12.29%)

@metamaskbot
Copy link
Collaborator

Builds ready [0e2b89e]
Page Load Metrics (1649 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26318081587317152
domContentLoaded1460179616249847
load14661834164910450
domInteractive24264535125
backgroundConnect65927168
firstReactRender1474312210
getState571212110
initialActions01000
loadScripts1079141012339244
setupStore85820199
uiStartup16972089191010751
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -649.08 KiB (-11.32%)
  • ui: 380 Bytes (0.00%)
  • common: -376.08 KiB (-4.40%)

Copy link

socket-security bot commented Feb 27, 2025

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@matthewwalsh0
Copy link
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@matthewwalsh0
Copy link
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@matthewwalsh0 matthewwalsh0 changed the base branch from main to mikesposito/bump-keyring-controller March 4, 2025 10:15
Copy link
Contributor

github-actions bot commented Mar 6, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Base automatically changed from mikesposito/bump-keyring-controller to main March 7, 2025 11:15
@metamaskbot
Copy link
Collaborator

Builds ready [41eade6]
Page Load Metrics (1863 ± 101 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15852354185719794
domContentLoaded15702199180416378
load158524401863210101
domInteractive25134483215
backgroundConnect9325616632
firstReactRender15119332713
getState6205294421
initialActions01000
loadScripts11761678137813263
setupStore86521199
uiStartup185941432229480230
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 76.42 KiB (1.24%)
  • ui: 128 Bytes (0.00%)
  • common: 15.89 KiB (0.15%)

@metamaskbot
Copy link
Collaborator

Builds ready [ad4e096]
Page Load Metrics (2073 ± 444 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint52720561775310149
domContentLoaded166060152031924444
load170260502073924444
domInteractive26367517436
backgroundConnect11136523115
firstReactRender1597362311
getState66023178
initialActions01000
loadScripts124949801560794381
setupStore85315116
uiStartup1938668923841005482
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 76.42 KiB (1.24%)
  • ui: 128 Bytes (0.00%)
  • common: 15.73 KiB (0.15%)

Comment on lines 8 to 9
transactionController: TransactionController,
networkController: NetworkController,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it make more sense / match our existing patterns better to pass in hooks to the actual methods you're calling rather than the full controllers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it definitely would.

In a future PR, we could even just pass in the messenger and invoke the controllers using the messenger actions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +25 to +41
throw rpcErrors.invalidInput(
`Chain ID must match the dApp selected network: Got ${requestChainId}, expected ${dappChainId}`,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm I'm not sure if this is the right rpc error... Though I'm looking at the others and this may be our best match 🤔

Copy link
Member Author

@matthewwalsh0 matthewwalsh0 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is our standard bad input error we use for all the transaction and signature calls from eth-json-rpc-middleware.

Though the EIP-5792 specification is still being finalised and I believe they're looking at formalising error codes for different scenarios so will likely extend this in future.

}

export function getTransactionReceiptsByBatchId(
controller: TransactionController,
Copy link
Contributor

@adonesky1 adonesky1 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here: could we just pass a method in rather than the whole controller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

export async function getCapabilities(
controller: TransactionController,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And same here: could we pass in a method rather than the whole controller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@metamaskbot
Copy link
Collaborator

Builds ready [28dccab]
Page Load Metrics (1882 ± 128 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint155324721894276133
domContentLoaded154723071820210101
load155224061882267128
domInteractive247035147
backgroundConnect9307656933
firstReactRender1467332010
getState4161283919
initialActions00000
loadScripts11431799138818488
setupStore75918168
uiStartup179236332275505242
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 76.42 KiB (1.24%)
  • ui: 128 Bytes (0.00%)
  • common: 15.77 KiB (0.15%)

Support batch transaction type.
@matthewwalsh0 matthewwalsh0 force-pushed the feat/atomic-batch-transactions branch from eb51b9c to e38a988 Compare March 7, 2025 21:43
@metamaskbot
Copy link
Collaborator

Builds ready [e38a988]
Page Load Metrics (2004 ± 125 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint173527102013256123
domContentLoaded172325581954228109
load172827332004261125
domInteractive27106402010
backgroundConnect10174534622
firstReactRender157430199
getState6122333517
initialActions01000
loadScripts12881919148317986
setupStore763262110
uiStartup199337472367466224
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 76.64 KiB (1.25%)
  • ui: 128 Bytes (0.00%)
  • common: 15.77 KiB (0.15%)

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review March 7, 2025 22:34
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners March 7, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants